package itsm.isperp.module.controller.app;

import itsm.isperp.framework.web.controller.TreeNodeController;
import itsm.isperp.module.entity.app.AppSystemHelp;
import itsm.isperp.module.service.app.AppSystemHelpService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * 系统帮助的控制器
 * 
 * @author lizx
 * @date 2013-7-27
 */
@Controller
@RequestMapping("app/systemHelp")
public class AppSystemHelpController extends TreeNodeController<AppSystemHelp> {

	@Autowired
	protected AppSystemHelpService appSystemHelpService;

	@Override
	public AppSystemHelpService getService() {
		return this.appSystemHelpService;
	}

	@Override
	public String getPageTitle() {
		return "系统帮助";
	}

	@RequestMapping("get/{id}")
	@ResponseBody
	@Override
	public AppSystemHelp get(@PathVariable("id") String id) {
		return this.getService().findOne(id);
	}

	@RequestMapping("getByCode/{code}")
	@ResponseBody
	public AppSystemHelp getByCode(@PathVariable("code") String code) {
		return this.getService().getByCode(code);
	}

	@RequestMapping("index/{id}")
	public ModelAndView index(@PathVariable("id") String id) {
		ModelAndView mv = new ModelAndView("app/systemHelp/index");
		mv.addObject("categorys", this.getService().getUserHelpList());
		AppSystemHelp helpInfo = null;
		if ("USER".equals(id)) {

			helpInfo = this.getService().getByCode("USER");
		} else {
			helpInfo = this.getService().findOne(id);
		}

		mv.addObject("helpInfo", helpInfo);
		return mv;
	}
}
